#include "../../mqserver/binding.hpp"

#include <iostream>
#include <gtest/gtest.h>

// NS_Binding::BindingPersist per("./data/meta.db");

// class PersistTest : public testing::Environment
// {
// public:
//     virtual void SetUp() override
//     {
//         per.createTable();
//     }

//     virtual void TearDown() override
//     {
//         // per.deleteTable();
//     }
// };

// TEST(persist_test, insert)
// {
//     per.insert(std::make_shared<NS_Binding::Binding>("exchange1", "queue1", "news.music.#", true));
//     per.insert(std::make_shared<NS_Binding::Binding>("exchange1", "queue2", "news.sport.#", true));
//     per.insert(std::make_shared<NS_Binding::Binding>("exchange2", "queue1", "news.music.pop", true));
//     per.insert(std::make_shared<NS_Binding::Binding>("exchange2", "queue2", "news.music.football", true));
// }

// TEST(persist_test, erase)
// {
//     per.erase("exchange1", "queue1");
// }

// TEST(persist_test, erase_exchange)
// {
//     per.removeExchangeBindings("exchange1");
// }

// TEST(persist_test, erase_queue)
// {
//     per.removeMsgQueueBindings("queue1");
// }

NS_Binding::BindingManager mag("./data/meta.db");

class BindingtTest : public testing::Environment
{
public:
    virtual void SetUp() override
    {
    }

    virtual void TearDown() override
    {
    }
};

// TEST(binding_test, insert)
// {
//     ASSERT_EQ(mag.size(), 1);
//     mag.addBinding("exchange1", "queue1", "news.music.#", true);
//     mag.addBinding("exchange1", "queue2", "news.sport.#", true);
//     mag.addBinding("exchange2", "queue1", "news.music.pop", true);
//     mag.addBinding("aaa", "bbb", "news.music.pop", true);
//     ASSERT_EQ(mag.size(), 5);
// }

// TEST(binding_test, delete)
// {

//     mag.deleteBinding("aaa", "bbb");
//     ASSERT_EQ(mag.size(), 4);
//     ASSERT_NE(mag.exists("aaa", "bbb"), true);
// }

// TEST(binding_test, delete_exchange)
// {

//     mag.deleteExchangeBindings("exchange1");
//     ASSERT_EQ(mag.size(), 2);
// }

// TEST(binding_test, delete_queue)
// {

//     mag.deleteMsgQueueBindings("queue1");
//     ASSERT_EQ(mag.size(), 1);
// }


int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    testing::AddGlobalTestEnvironment(new BindingtTest());

    
    return RUN_ALL_TESTS();
}